package net.m510.autosurfer.common;

import java.io.IOException;
import java.util.logging.Level;

import net.m510.autosurfer.core.DocumentResponseHandler;
import net.m510.autosurfer.core.log.LogUtils;
import net.m510.autosurfer.core.process.AbstractGetProcess;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jsoup.nodes.Document;

public abstract class DocumentGetProcess extends AbstractGetProcess<Document> {
	private ResponseHandler<Document> responseHandler = new DocumentResponseHandler();
	public DocumentGetProcess() {
		this(null,null);
	}
	public DocumentGetProcess(CloseableHttpClient client,HttpClientContext context) {
		super(client, context);
	}
	
	@Override
	public Document process(Document doc) throws ClientProtocolException, IOException {
		Document out = super.process(doc);
		LogUtils.logTitle(log, Level.FINE, out);
		LogUtils.logForms(log,Level.FINE,out.getAllElements().forms());
		return out;
	}
	

	@Override
	protected ResponseHandler<Document> getResponseHandler() {
		return responseHandler;
	}
}
